/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

API.form = API.form || {};

API.form.Input = function(config){
    
    API.apply(this, config, {
        text: '',
        name: '',
        class: 'basic-form-input'
    });  
    
    var t = document.createTextNode(this.text),
        i = document.createElement('input'),
        p = document.createElement('p');

    i.name = this.name;
    i.className = this.class;
   
    p.appendChild(t);
    p.appendChild(i);
    
    this.DOM = p;
    this.input = i;
    
};
    
API.apply(API.form.Input.prototype, {
    
    hide : function(){
        this.DOM.style.display = 'none';
    },

    show : function(){
        this.DOM.style.display = 'block';
    },

    enable : function(){
        this.input.readOnly = false;
    },

    disable : function(){
        this.input.readOnly = true;
    },

    getName : function(){
        return this.input.name;
    },

    setValue : function(value){
        this.input.value = value;
    }
    
}); 
